import java.util.*;

public class Input {
    static final Scanner sc = new Scanner(System.in);
    static private Input instance = null;

    private Input() {};

    static public Input getInstance() {
        if (instance == null)
            instance = new Input();
        return instance;
    }

    static public int getInt(String prompt, int start, int end) {
        int num;

        while (true) {
            System.out.printf(prompt);
            num = sc.nextInt();
            if (num >= start && num <= end)
                break;
        }

        return num;
    }

    static public int getInt(String prompt, int end) {
        return getInt(prompt, Integer.MIN_VALUE, end);
    }

    static public int getInt(String prompt) {
        return getInt(prompt, Integer.MIN_VALUE, Integer.MAX_VALUE);
    }

    static public int getInt() {
        return getInt("请输入: ", Integer.MIN_VALUE, Integer.MAX_VALUE);
    }

    static public char getChar(String prompt) {
        System.out.printf(prompt);
        return sc.next().charAt(0);
    }

    static public String getStr(String prompt) {
        String s;
        boolean flags = false;

        System.out.printf(prompt);
        s = sc.nextLine();

        while (s.length() == 0) {
            if (flags) {
                System.out.printf(prompt);
            }
            s = sc.nextLine();
            flags = true;
        }
        return s;
    }

/*
 *     static public void main(String [] args) {
 *         Input.getInt("请输入一个整型: ", 0, 100);
 *         String s = Input.getStr("请输入字符串: ");
 *
 *         System.out.printf("s = %s, len = %d\n", s, s.length());
 *     }
 */
}
